package com.bdqn.hospital.mapper;

import com.bdqn.hospital.pojo.Patient;
import org.apache.ibatis.annotations.Insert;
import com.bdqn.hospital.pojo.Patient;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Select;

/**
 * @version : 1.0
 * @Author :guogd
 * @createTime: 2023/03/01 14:28
 * @Description: com.bdqn.hospital.mapper
 */
@Mapper
public interface PatientMapper {
    /**
     * 根据身份证获取病人信息
     * @param idCard
     * @return
     */
    @Select("select * from patient where id_card=#{idCard}")
    Patient getByIdCard(String idCard);

    /**
     * 根据医保卡获取病人信息
     */
    @Select("select * from patient where id_medicare=#{idMedicare}")
    Patient getByIdMedicare(String idMedicare);

    /**
     * 新增病人细信息
     * @return
     */
    @Insert("insert into patient values(null,#{name},#{birthday},#{sex},#{address},#{phone},#{idCard},#{isMedicare},#{idMedicare},now(),null)")
    Integer addPatient(Patient patient);
    /**
     * 根据id查询病人信息
     * @param id
     * @return
     */
    @Select("select * from patient where id =#{id}")
    Patient getPatientById(@Param("id") Integer id);

}
